<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/media/css/forms.css" />
<link rel="stylesheet" type="text/css" href="/media/css/base.css" />
<link rel="stylesheet" type="text/css" href="/media/css/monthpicker.css" />
<script type='text/javascript' src='/media/js/jquery-1.4.4.min.js'></script>

<script type='text/javascript' src='/media/js/jquery-ui-1.8.6.custom.min.js'></script>
<link rel='stylesheet' type='text/css' href='/media/css/fullcalendar.css' />
<script type='text/javascript' src='/media/js/fullcalendar.min.js'></script>
<script type="text/javascript" src="/media/js/monthpicker.min.js"></script>

<script type='text/javascript'>

	$(document).ready(function() {

		$(".xbtn-slide").click(function(){
			$("#xpanel").slideToggle("slow");
			$(this).toggleClass("xactive"); return false;
		});
			
			
		$('#calendar').fullCalendar({

			height: 480,
			{% if xcalmonth %}
			month: {{xcalmonth}},
			{% endif %}
			{% if xyear %}
			year: {{xyear}},
			{% endif %}
			header: {
			left: 'prev,next today',
			center: 'title',
			right: 'month,agendaWeek,agendaDay'
			},
		
			
			editable: true,
			
			events: "/worklist/ajanda/json/?cid={{xcid}}&month={{xmonth}}&year={{year}}",
			
			eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {

		        /*
		            alert(
		            event.title + "( " + event.id + " ) was moved " +
		            dayDelta + " days and " +
		            minuteDelta + " minutes.");
                */
		        if (allDay) {
		           // alert("Event is now all-day");
			           xallDay = "E";
		        }else{
		           // alert("Event has a time-of-day");
			           xallDay = "H";
		        }

		      /*  if (!confirm("Güncellensin mi?")) {
		            revertFunc();
		        }
		        else
		        {*/
		        	ajanda_guncelle(event.id,'S',dayDelta,minuteDelta,xallDay);
		        //}

		    },
					
			eventResize: function(event,dayDelta,minuteDelta,revertFunc) {

		        /*alert(
		            "The end date of " + event.title + "( "+event.id+ " ) has been moved " +
		            dayDelta + " days and " +
		            minuteDelta + " minutes."
		        );
				*/
		      /*  if (!confirm("Güncellensin mi??")) {
		            revertFunc();
		        }
		        else 
		        {*/
		           	ajanda_guncelle(event.id,'E',dayDelta,minuteDelta,'H');
		              	
		        //}

		    },
					
			
			loading: function(bool) {
		    	var xelement = document.getElementById("loading");
				if (bool) { $('#loading').show(); xelement.innerHTML="yüklüyor.."; }
				else { $('#loading').hide(); }
			}
			
		});

		
		
		
	});

</script>
<script type="text/javascript">
$(function(){		
	
	
	$("#example_3").monthpicker({
		elements: [
			{tpl:"month",opt:{
				value: {% if xmonth %}{{xmonth}}{%else%}{{ xbugunmonth }}{%endif%}
			}},
			{tpl:"year",opt:{
				range: "-5~5",
				value: {% if xyear %}{{xyear}}{%else%}{{xbugunyear}}{%endif%}
			}}
		],
		onChanged: callback
	});
	$("#example_4").monthpicker({
		elements: [
			{tpl:"year",opt:{
				range: "-10~2",
				value: 2005
			}},
			{tpl:"quarter"}
		],
		onChanged: callback
	});
});

function callback(data,$e){
var str = "?";
for(key in data) {
	str += key + "=" + data[key]+ "&";
}

window.location.href = str
}

function donemgetir()
{
	var xstr = document.getElementById("id_donem");
	window.location.href= xstr.value
}
</script>

<script language="Javascript">
function AJAX() {
   var ajax = false;
   // Internet Explorer (5.0+)
   try {
    ajax = new ActiveXObject("Msxml2.XMLHTTP");  // yeni versiyon xmlhttp
   } catch (e) {
       try {
        ajax = new ActiveXObject("Microsoft.XMLHTTP");  // eski versiyon xmlhttp
      } catch (e) {
        ajax = false;
      }
    }
   // Mozilla ve Safari
   if ( !ajax && typeof XMLHttpRequest != 'undefined' ) {
     try{
        ajax = new XMLHttpRequest();
     }catch(e) {   
        ajax = false;
     }
    }
    // Diger
   if ( !ajax && window.createRequest ) {
          try{
        ajax = window.createRequest();
     }catch(e) { 
        ajax = false;
     }
    }
     return ajax;
}

 
var deneme=0;
function removeSpaces(string) {
	 return string.split(' ').join('');
	}

function ajanda_guncelle(xisid,xtip,xgun,xdk,xtumgun) {
ajax = new AJAX();

var xelement = document.getElementById("ajaxloading");
//var hidden_element= document.getElementById("sonucx");
//element.innerHTML=random_num;

ajax.open("GET", "/worklist/ajanda/guncelle/?isid="+xisid+"&tip="+xtip+"&gun="+xgun+"&dk="+xdk+"&tumGun="+xtumgun, true);
ajax.onreadystatechange = function() {
		if (ajax.readyState < 4 )
		{ 
		 $("#ajaxloading").fadeIn('slow');
		 
		 xelement.innerHTML = "Lutfen Bekleyiniz ...";
		} 
		
		if (ajax.readyState == 4 && ajax.status == 200) {

			
			
			xelement.innerHTML = ajax.responseText ;
			
			$("#ajaxloading").fadeOut('slow');
		
			
		}

    }
	
    ajax.send(null);
	
}

function ajanda_cihaz_getir() {
	ajax = new AJAX();

	var xvar = document.getElementById("id_cid");

	var xelement = document.getElementById("ajaxcihaz");
	//var hidden_element= document.getElementById("sonucx");
	//element.innerHTML=random_num;

	ajax.open("GET", "/worklist/ajanda/cihaz/?cid="+xvar.value, true);
	ajax.onreadystatechange = function() {
			if (ajax.readyState < 4 )
			{ 
			
			 
			 xelement.innerHTML = "<select><option>Lütfen bekleyiniz...</option></select>";
			} 
			
			if (ajax.readyState == 4 && ajax.status == 200) {

				
				if (ajax.responseText!="%")				
				{
					xelement.innerHTML = ajax.responseText;
				}
				else
				{
					xelement.innerHTML = null;
				}
					
				
			}

	}
		
	    ajax.send(null);
		
}

</script>
<style type='text/css'>

	body {
		
		text-align: center;
		font-size: 12px;
		font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
		}
		
	#loading {
		position: absolute;
		top: 5px;
		right: 130px;
		z-index:2;
		background-color: yellow;
		}

	#calendar {
		width: 900px;
		margin: 0 auto;
		}
	
	a:focus {
	outline: none;
	}
	#xpanel {
		background: #CFCFCF;
		height: 67px;
		display: none;
		color: white;
		font-weight: bold;
	}
	.xslide {
		margin: 0;
		padding: 0;
		border-top: solid 1px #422410;
		background: url(/media/img/admin/btn-slide.gif) no-repeat center top;
	}
	.xbtn-slide {
		
		text-align: center;
		width: 144px;
		height: 30px;
		padding: 5px 5px 0 0;
		margin: 0 auto;
		
		display: block;
		font: bold 120%/100% Arial, Helvetica, sans-serif;
		color: rgb(0,100,255);
		
	}
	.xactive {
		background-position: right 12px;
	}
		
</style>


</head>
<body>
<div id='ajaxloading' style="position: absolute; top: 5px; right: 130px; z-index:2; background-color: yellow;" ></div>
<div id='loading'></div>

  <div id="userx" align="right" style="font-size: 12px; margin-top:5px;"> 
  {% if user.username %}<a href="/accounts/profile/{{user.username}}/edit/">({{user.username}})</a>&nbsp|&nbsp<a href="/accounts/logout">Çıkış</a>{% else %}<a href="/accounts/login">Giriş Yap</a>{%endif%}
  
  </div>
  <div id="xpanel">
		<table>
		<tr style="padding: 0; border: none;">
			<td style="border:none; width: 50%; vertical-align: middle;">
				<div>
				<select onchange="ajanda_cihaz_getir();" name="cid" id="id_cid">
				<option value="%" {% ifequal xcid "%"%}selected="selected"{%endifequal%}>Hepsi</option>
				{% for cih in xcihazlar %}
				<option value="{{cih.id}}">{{cih}}</option>
			    
				{% endfor %}
				</select>
				</div>
			</td>
			<td align="left" style="border: none; width: 50%; vertical-align=middle;">
				<div id="ajaxcihaz"></div>
			</td>
		</tr>
		<tr style="padding: 0; border: none;">
		<td colspan="2" style="border: none; width: 100%; vertical-align:middle;"><div align="center" class="MonthPicker" id="example_3" style="width:100%;" title="Seçtiğiniz yıl ve ay'a gider"></div></td>
		</tr>
		</table>
  </div>
  <p class="xslide"><a href="#" class="xbtn-slide" style="color: white; margin-bottom: 2px;">Filtreler</a></p>
 
  


<div id='calendar'></div>
</body>
</html>

